Skip to content

feat: Add spoiler channel flag and functions - #3252

Open
ToothyDev wants to merge 38 commits into
masterfrom
feat/spoiler-channels
Open

ToothyDev wants to merge 38 commits into
masterfrom
feat/spoiler-channels

Conversation

@ToothyDev

@ToothyDev ToothyDev commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This adds ChannelFlags.is_spoiler_channel (following https://docs.discord.food/resources/channel#channel-flags) as well as a .spoiler property to all applicable channel types (all except category). Same goes for making it possible to create these channels via the regular channel creation methods, again with the exception of category channels. Channel editing with this flag is also functional.

Now that it's officially documented, here's the ddocs PR: discord/discord-api-docs#8465

Depends on discord/discord-api-docs#8465

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does
  • I have read the Contributing Guidelines

@ToothyDev ToothyDev added upcoming discord feature Involves a feature not yet fully released by Discord on hold labels Jun 5, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Pycord Jun 5, 2026
@pycord-app

pycord-app Bot commented Jun 5, 2026

Copy link
Copy Markdown

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3252/head:pr-3252
git checkout pr-3252

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3252/head

@ToothyDev ToothyDev added the hold: testing This pull request requires further testing label Jun 5, 2026

@Lulalaby Lulalaby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a shower <3

@Lulalaby Lulalaby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took a shower apparently

@Lulalaby Lulalaby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can someone request changes reminding me to add editing & creating channels with that flag
and whatever else i may have forgotten

@Soheab Soheab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a way for bots to create this kind of channel

This message was sponsored by toothyfernsan on discord.

@Soheab Soheab added hold: changelog This pull request is missing a changelog entry and removed hold: changelog This pull request is missing a changelog entry labels Jun 5, 2026
@ToothyDev

Copy link
Copy Markdown
Contributor Author

I tested it with all but MediaChannels since I don't have access to those anywhere, but I'd still like a second pair of testing eyes on this

@ToothyDev ToothyDev moved this from Todo to In Progress in Pycord Jun 5, 2026
@ToothyDev

Copy link
Copy Markdown
Contributor Author

Also, creating a channel with this turned on isn't possible unfortunately, gotta create + edit

@Paillat-dev Paillat-dev added this to the 2.9.0rc1 milestone Jun 7, 2026
ToothyDev and others added 3 commits June 22, 2026 22:13
Signed-off-by: Lala Sabathil <lala@pycord.dev>
Signed-off-by: Lala Sabathil <lala@pycord.dev>
@github-actions github-actions Bot added the invalid This doesn't seem right label Jul 30, 2026
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot closed this Jul 30, 2026
@github-actions github-actions Bot locked as spam and limited conversation to collaborators Jul 30, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Pycord Jul 30, 2026
@Pycord-Development Pycord-Development unlocked this conversation Jul 30, 2026
Co-authored-by: Lala Sabathil <lala@pycord.dev>
Signed-off-by: ToothyDev <55001472+ToothyDev@users.noreply.github.com>
Comment thread discord/channel.py Outdated
Paillat-dev
Paillat-dev previously approved these changes Sep 18, 2026
@Paillat-dev

Copy link
Copy Markdown
Member

Thanks !

@vmphase vmphase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this PR add any kind of support for spoiler on StageChannel, while documentation explicitly says:

IS_SPOILER_CHANNEL ... Can be set on all textual guild channels and voice channels (not GUILD_STAGE).

@ToothyDev

Copy link
Copy Markdown
Contributor Author

Why does this PR add any kind of support for spoiler on StageChannel, while documentation explicitly says:

IS_SPOILER_CHANNEL ... Can be set on all textual guild channels and voice channels (not GUILD_STAGE).

To stay internally consistent, because NSFW also doesn't work on stage channels, but Pycord supports it, it CAN be passed, it just has no effect. And actually, both toggles do exist (and work) in the client UI. Basically, everything works except it having an actual effect on the channel. So, while yes, it doesn't actually do anything, I still think it's worth keeping for internal consistency and because Discord might eventually make it work for stage channels (same for nsfw)

Comment thread discord/channel.py Outdated
Comment thread discord/guild.py Outdated
Comment thread discord/guild.py Outdated
Comment thread discord/guild.py Outdated
@vmphase

vmphase commented Sep 18, 2026

Copy link
Copy Markdown
Member

st has no effect. And actually, both toggles do exist (and work) in the client UI. Basically, everything works except it having an actual effect on the channel. So, while yes, it doesn't actually do anything, I still think it's worth keeping for internal consistency and because Discord might eventually make it work for stage channels (same for nsfw)

I see. If the development team is fine with this, sure.

@Paillat-dev

Copy link
Copy Markdown
Member

From the docs

this channel is a Spoiler Channel i.e. users must opt in to view its contents. Can be set on all textual guild channels and voice channels (not GUILD_STAGE). Can only be set if channel’s nsfw is false

Two things:

  1. We should not support the spoiler param for stage channel if it is explicited this way that there is no support.
  2. It says: "Can only be set if channel’s nsfw is false". Would this mean that setting spoiler to true on a nsfw channel would fail, or does it automatically flip it to false in the backend ? I assume the latter, but I am not sure we should take it for granted `

@Lulalaby

Lulalaby commented Oct 2, 2026

Copy link
Copy Markdown
Member

the client switches it back. i think the api rejects it

@ToothyDev

Copy link
Copy Markdown
Contributor Author

Either they changed the behavior or I remember wrong, but:
NSFW channel with edit(spoiler=True) does not work, you also have to explicitly pass nsfw=False
Spoiler channel with edit(nsfw=True) does work, even without passing spoiler=False

Comment thread discord/guild.py Outdated
Comment thread discord/channel.py Outdated
Comment thread discord/channel.py
Comment thread discord/channel.py Outdated
Comment thread discord/channel.py
HTTPException
Editing the channel failed.
"""
if "spoiler" in options:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nsfw docstring says passing nsfw=True to a spoiler channel converts it to NSFW, but this block only runs when spoiler is passed. edit(nsfw=True) alone never clears is_spoiler_channel, so the documented behavior isn't implemented. Either handle nsfw=True independently of spoiler (clear the bit) or drop that sentence from the docstring.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this with the current code. Passing nsfw=True to a spoiler channel converts it, and channel.spoiler returns False as expected

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to make sure I understand @ToothyDev, spoiler to nsfw implicitly works fine but nsfw to spoiler implicitly fails ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I think this was a dicussion way early in the PR where catching all the specific cases was really complicated and so it was scrapped, since the API doesn't reject it, it just doesn't do anything

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the only explicitly documented behavior is

Can only be set if channel's nsfw is false

for spoiler state, and nothing about the other way around. I am not sure however if we should still rely on the API for the rest.

@Lulalaby Do you have some insight maybe ?

@vmphase

vmphase commented Oct 4, 2026

Copy link
Copy Markdown
Member

Will this PR ever merge? xD

Continuously fixing bugs alongside with introducing new ones.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API reflection Discord API isn't correctly reflected PA: Maintainers pending

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants